\ProvidesPackage{espacs}

% User-defined colors
\definecolor{DarkGreen}{rgb}{0, .5, 0}
\definecolor{DarkBlue}{rgb}{0, 0, .5}
\definecolor{DarkRed}{rgb}{.5, 0, 0}
\definecolor{LightGray}{rgb}{.8, .8, .8}

% Settings for listing class
\lstset{  
  language=[ISO]C++,                       % The default language
  basicstyle=\sf,                          % The basic style
  backgroundcolor=\color{LightGray},       % Set listing background
  keywordstyle=\color{DarkBlue}\bfseries,  % Set keyword style
  commentstyle=\color{DarkGreen}\itshape, % Set comment style
  stringstyle=\color{DarkRed},             % Set string constant style
  extendedchars=true                       % Allow extended characters
}

% Reference commands
\newcommand{\secref}[1]{\S~\ref{#1}}
\newcommand{\appref}[1]{Appendice \ref{#1}}
\newcommand{\figref}[1]{Fig. \ref{#1}}
\newcommand{\tabref}[1]{Tab. \ref{#1}}
\newcommand{\lemmaref}[1]{\emph{Lemma \ref{#1}}}
\newcommand{\theoremref}[1]{\emph{Teorema \ref{#1}}}
\newcommand{\remarkref}[1]{\emph{Osservazione \ref{#1}}}
\newcommand{\corollaryref}[1]{\emph{Corollario \ref{#1}}}
\newcommand{\extref}[1]{\S~#1}
\newcommand{\listingref}[1]{\emph{Listato} \ref{#1}}

% Double square brackets for jump operator
\newcommand{\ldbracket}{\left[\hspace{-1.5pt}\left[}
\newcommand{\rdbracket}{\right]\hspace{-1.5pt}\right]}

% Trace operators
\newcommand{\jump}[1]{\left[ #1\right]}
\newcommand{\jumpn}[1]{\left[ #1\right]_{\N}}
\newcommand{\jumps}[1]{\ldbracket #1 \rdbracket}
\newcommand{\avg}[1]{\left\lbrace #1\right\rbrace}

% Differential
\newcommand{\ud}{~\mathrm{d}}
\newcommand{\uD}{~\mathrm{D}}
\newcommand{\nablah}{\nabla_{h}}

% Trace
\newcommand{\tr}{\mathrm{tr}}

% Non-dimensional numbers
\newcommand{\Reynolds}{\mathrm{Re}}
\newcommand{\Biot}{\mathrm{Bi}}

% Integrals
\newcommand{\intK}[1]{\int_{K} #1 \ud{\bf x}}
\newcommand{\intpK}[1]{\int_{\partial K} #1 \ud\sigma}
\newcommand{\inte}[1]{\int_{e} #1 \ud\sigma}
\newcommand{\intOmega}[1]{\int_{\Omega} #1 \ud{\bf x}}
\newcommand{\intGamma}[1]{\int_{\Gamma} #1 \ud\sigma}
\newcommand{\intE}[1]{\int_{\mathcal{E}} #1 \ud\sigma}
\newcommand{\intpKp}[1]{\int_{\partial K_{+}} #1 \ud\sigma}
\newcommand{\intpKm}[1]{\int_{\partial K_{-}} #1 \ud\sigma}
\newcommand{\intOT}[1]{\int_0^T #1 \ud t}
\newcommand{\intOtau}[1]{\int_0^{\tau} #1 \ud t}
\newcommand{\intOmegaOT}[1]{\int_{\Omega\times\left[0, T\right]} #1 \ud{\bf x}\ud t}
\newcommand{\intKOT}[1]{\int_{K \times\left[0, T\right]} #1 \ud{\bf x}\ud t}
\newcommand{\intpKOT}[1]{\int_{\partial K \times\left[0, T\right]} #1 \ud\sigma\ud t}
\newcommand{\intpKpOT}[1]{\int_{\partial K_{+} \times\left[0, T\right]} #1 \ud\sigma\ud t}
\newcommand{\intab}[1]{\int_{a}^{b} #1 \ud x}

% Sums
\newcommand{\sumK}{\sum_{K\in\mathcal{T}_h} }

% Product notations
\newcommand{\intprod}[3]{\left( #1, #2 \right)_{#3}}
\newcommand{\crochet}[2]{\left< #1, #2 \right>}
\newcommand{\diad}[2]{#1 \otimes #2}

% Equal by definition
\newcommand{\eqbydef}{\stackrel{\mathrm{def}}{=}}

% Dot product
\newcommand{\dotprod}[2]{ #1 \cdot #2}

% A command to increase row height
\newlength{\myVSpace}
\setlength{\myVSpace}{6mm}
\newcommand\xstrut{
    \raisebox{-.5\myVSpace}{\rule{0pt}{\myVSpace}}
}

% Boldface symbols and letters
\newcommand{\BETA}{\boldsymbol{\beta}}
\newcommand{\U}{{\bf u}}
\newcommand{\V}{{\bf v}}
\newcommand{\NABLA}{\boldsymbol{\nabla}}
\newcommand{\NABLAH}{\boldsymbol{\nabla}_h}
\newcommand{\N}{{\bf n}} 
\newcommand{\G}{{\bf g}}
\newcommand{\W}{{\bf w}}
\newcommand{\E}{{\bf e}}
\newcommand{\EPSILON}{\boldsymbol{\epsilon}}
\newcommand{\bS}{{\bf s}}
\newcommand{\X}{{\bf x}}
\newcommand{\ZERO}{{\bf 0}}

% Divergence operator
\newcommand{\Div}{\mathrm{div}}

% One half
\newcommand{\half}{\frac{1}{2}}

% Id est, exempli gratia and et alii
\newcommand{\ie}{\emph{i.e.}~}
\newcommand{\eg}{\emph{e.g.}~}
\newcommand{\etal}{\emph{et al.}~}

% Time derivative
\newcommand{\partialt}[1]{\frac{\partial #1}{\partial t}}

% Theorem environments
\newtheorem{theorem}{Theorem}
\newtheorem{lemma}{Lemma}
\newtheorem{remark}{Remark}
\newtheorem{corollary}{Corollary}

% Proof environment
\newenvironment{proof}
    {\emph{Proof.}}
    {\begin{flushright}
        \rule{1ex}{1ex}
     \end{flushright}}

% Bilinear form
\newcommand{\bilin}[3]{#1\left(#2,#3\right)}
\newcommand{\BILIN}[3]{#1\left(#2;#3\right)}

% Function
\newcommand{\function}[2]{#1\left( #2\right)}

% Norms
\newcommand{\norm}[1]{\| #1\|}
\newcommand{\tnorm}[1]{\vert\hspace{-1pt}\Vert #1\Vert\hspace{-1pt}\vert}
\newcommand{\sbnorm}[1]{|] #1[|}
\newcommand{\module}[1]{| #1 |}

% Hilbert and Sobolev spaces
\newcommand{\hilbertL}[2]{L^{#1}\left( #2\right)}
\newcommand{\hilbert}[2]{H^{#1}\left( #2\right)}
\newcommand{\sobolev}[3]{W^{#1, #2}\left( #3\right)}
\newcommand{\HilbertL}[2]{{\bf L}^{#1}\left( #2\right)}
\newcommand{\Hilbert}[2]{{\bf H}^{#1}\left( #2\right)}
\newcommand{\Sobolev}[3]{{\bf W}^{#1, #2}\left( #3\right)}

% Darcy projection operator
\newcommand{\Ph}[1]{\mathcal{P}_h #1}
\newcommand{\Qh}[1]{\mathcal{Q}_h #1}

% 3-component vector
\newcommand{\vthree}[3]{
\left[
    \begin{array}{l}
        #1 \\ #2 \\ #3
    \end{array}
\right]}

% Sign operator
\newcommand{\sign}[1]{\mathrm{sign}\left( #1 \right)}

% Big O
\newcommand{\bigO}[1]{\mathcal{O}\left( #1 \right)}

% Max within a set
\newcommand{\maxset}[1]{\max\left\lbrace #1 \right\rbrace}

% Couple
\newcommand{\couple}[2]{\left( #1, #2\right)}

% Set
\newcommand{\set}[2]{\left\lbrace #1 | #2 \right\rbrace}

% Real set
\newcommand{\RR}{\mathbb{R}}

% Polynomial spaces
\newcommand{\Pk}[1]{\mathbb{P}_k\left( #1\right)}

% Space C^p
\newcommand{\C}[2]{C^{#1}\left( #2\right)}

% Kernel
\newcommand{\kernel}[1]{\mathrm{ker}\left( #1 \right)}

% Interval
\newcommand{\closedint}[2]{\left[ #1, #2\right]}
\newcommand{\openint}[2]{\left( #1, #2\right)}

% Superscript for iteration
\newcommand{\iter}[1]{^{\left( #1\right)}}

% Scientific format
\newcommand{\e}[1]{\cdot 10^{#1}}

% 'If' and 'otherwise' to be used in case enumeration
\newcommand{\If}[1]{\mathrm{if}~#1}
\newcommand{\Otherwise}{\mathrm{otherwise}}
\newcommand{\Se}[1]{\mathrm{se}~#1}
\newcommand{\Altrimenti}{\mathrm{altrimenti}}

% Diagonal 
\newcommand{\diag}[1]{\mathrm{diag}\left( #1\right)}

% Series
\newcommand{\series}[2]{\lbrace #1\rbrace_{#2}}

% Th
\newcommand{\Th}{\mathcal{T}_h}

% Units of measure
\newcommand{\uW}{\mathrm{W}}
\newcommand{\um}{\mathrm{m}}
\newcommand{\ucm}{\mathrm{cm}}
\newcommand{\umm}{\mathrm{mm}}
\newcommand{\uK}{\mathrm{K}}

% A command to set row height
\newlength{\rowH}
\newcommand{\setH}[1]{
\setlength{\rowH}{#1}
\raisebox{-.5\rowH}{\rule{0pt}{\rowH}}
}

% A command to print C++ instructions
\newcommand{\cpp}[1]{\lstinline!#1!}

% Restriction to
\newcommand{\restrto}[2]{\left. #1\right|_{#2}}
